<template>
  <view class="page">
    <!-- #ifdef H5-ONLY -->
    <theme-navbar :is-white="false" :title="title" :custom-back="goBack" style="z-index: 99999"></theme-navbar>
    <!-- #endif -->
    <view class="supervision-search-lay" :style="{'top': isHideNav ? 0 : '44px'}">
      <u-search
        class="supervision-search"
        shape="round"
        :clearabled="true"
        :showAction="true"
        actionText="确定"
        :animation="true"
        placeholder="请输入关键词"
        v-model="searchKey"
        @custom="toSearchList"
      ></u-search>
    </view>
    <view class="content u-page">
      <me-table
        :i="0"
        :index="0"
        :top="110"
        :load-data="loadData"
        :height="getListViewHeight()"
        :init-load="false"
        ref="mescrollItem0"
      >
        <view class="list-lay" slot-scope="d" @click="toDetail(d.data)">
          <view class="content-title-lay">
            <text>所属组织名称：{{ d.data.orgName || '' }}</text>
          </view>
          <view class="content-title-lay">
            <text>区域名称：{{ d.data.prohibitName || '' }}</text>
          </view>
          <view class="content-title-lay">
            <text>区域类型：{{ d.data.prohibitClassifyCode == '0101' ? '幼儿园' : '中小学' }}</text>
          </view>
          <view class="content-title-lay">
            <text>地址：{{ d.data.prohibitAddr || '' }}</text>
          </view>
        </view>
      </me-table>
    </view>
    <view class="submit-btns btn-other-cls">
      <u-button class="u-btn" type="primary" @click="addSchool">
        添加
      </u-button>
    </view>
  </view>
</template>
<script>
  import MescrollMoreMixin from "@/components/mescroll-uni/mixins/mescroll-more.js";
  import meTable from '@/components/me-table.vue';
  import queryService from '@/service/query/query.service.js';
  export default {
    components: { meTable },
    mixins: [ MescrollMoreMixin ],
    data () {
      return {
        searchKey: "",
        just: '',
        title:'中小学列表',
        userInfo: null
      }
    },
    mounted () {
      
    },
    methods: {
      getListViewHeight() {
        let p = this.$u.sys().windowHeight - 44 - 48 - uni.upx2px(10) - this.$u.sys().statusBarHeight;
        // #ifdef H5-DINGDING || H5-WECHAT
        p = this.$u.sys().windowHeight - uni.upx2px(10) - 48 - this.$u.sys().statusBarHeight;
        // #endif
        return p  + "px";
      },
      // 列表数据请求
      loadData(page) {
        let userData = uni.getStorageSync("user")
        this.userInfo = JSON.parse(userData);
        let param = {
          page: page.num,
          limit: page.size,
          ownOrgUuid: this.userInfo.orgUuid,
          prohibitName: this.searchKey
        };
        return new Promise((resolve) => {
          queryService.prohibitList(param).then(res => {
            if (res.success) {
              resolve({
                count: res.count,
                data: [...res.data,],
              });
            } else {
              resolve({
                count: 0,
                data: [],
              })
            }
          }).catch(err => {
            resolve({
              count: 0,
              data: [],
            });
          });
        })
      },
      // 查询
      toSearchList () {
        // this.getMescroll(0).triggerDownScroll();
        if (this.$u.test.isEmpty(this.searchKey)) {
          this.$u.toast('请输入关键字');
          return;
        }
        this.$refs['mescrollItem0'].refresh();
      },
      // 跳转详情
      toDetail (data) {
        this.$u.route({
          url: "pages/query/school/addSchoolCoordinate",
          params: {
            type: "edit",
            prohibitUuid: data.prohibitUuid,
          },
        });
      },
      addSchool() {
        this.$u.route({
          url: "pages/query/school/addSchoolCoordinate",
          params: {
            type: "add",
          },
        });
      }
    }
  }
</script>
<style scoped lang="scss">
  .page{
    padding: 0;
  }
  .supervision-search-lay {
		background-color: #fff;
		position: fixed;
		z-index: 999;
		width: 100%;
		overflow: hidden;
	}
  .supervision-search {
		padding: $cm-search-padding-row $cm-search-padding-column;
	}
  .content {
		background-color: #F3F4F5 ;
    min-height: 100%;
	}
	.list-lay{
		// border-bottom: 2rpx solid $u-border-color;
		padding: 20rpx 20rpx;
		background-color: #FFF;
    margin: 20rpx;
    border-radius: 15px;
	}
  .content-title {
    font-weight: 600;
    font-size: 16px;
    color: black;
  }
  .content-title-lay {
    padding:5px 3px;
  }
</style>